package com.wzvtc.mock_service.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                // 设置访问源地址
                .allowedOriginPatterns("*")
                //
                .allowedHeaders("Content-Type", "Content-Length", "X-Requested-With", "Access-Control-Request-Method", "Access-Control-Request-Headers")
                .allowedMethods("GET", "POST", "PUT", "DELETE")
                .allowCredentials(true);
    }
}